use crate::rbatis::crud_table;

use rbatis::DateTimeNative;
use rbson::DateTime;
use serde_derive::{Deserialize, Serialize};
use validators::semver::Op;

use crate::models::menu::{Menu, MenuVo};
use crate::models::role::{Role, RoleVo};

#[crud_table]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SysUser {
    pub user_id: Option<u64>,
    pub user_name: Option<String>,
    pub age: Option<u64>,
    pub phone: Option<String>,
    pub create_time: Option<DateTimeNative>,
    pub password: Option<String>,
    pub org_id: Option<String>,
    pub company_id: Option<String>,
    pub state: Option<u64>,
    pub del_flag: Option<u64>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UserVo {
    pub id: Option<i64>,
    pub user_name: Option<String>,
    pub age: Option<u64>,
    pub page_num: Option<u64>,
    pub page_size: Option<u64>,
    pub create_time: Option<DateTimeNative>,
    pub start_time: Option<DateTimeNative>,
    pub end_time: Option<DateTimeNative>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UserLoginVo {
    pub user_name: Option<String>,
    pub password: Option<String>,
    pub bar_code: Option<String>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UserRoleMenuVo {
    pub user_id: Option<u64>,
    pub user_name: Option<String>,
    pub access_token: Option<String>,
    pub roles: Option<Vec<Role>>,
    pub menus: Option<Vec<Menu>>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ResetPasswordReq {
    pub user_id: u64,
    pub origin_password: String,
    pub new_password: String,
}
